//
//  Record.h
//  Estimation
//
//  Created by Safeneeds-MacBookPro on 2013/07/03.
//  Copyright (c) 2013年 topsign. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface Record : NSObject{

}

enum DataType
{
    NUMBER,
    STRING,
    DATE
};

enum RecodeMode
{
    NEW,
    UPDATE
};

@property (nonatomic, retain) NSString *tableName;
@property (nonatomic, retain) NSMutableDictionary *keyFields;
@property (nonatomic, retain) NSMutableDictionary *fields;
@property (nonatomic) enum RecodeMode  mode;

-(id)initWithTableName:(NSString *) name;

-(int) doSave;
-(int) doDel;
-(int) loadFromDB;

-(char *)getInsertSql;
-(char *)getDelSql;
-(char *)getUpdateSql;
-(char *)getLoadSql;

-(int) updateField:(NSString *)fieldName;

-(void) removeField:(NSString *)key;
-(void) addField:(NSString *)key value:(id) value type:(enum DataType ) type;
-(void) addField:(NSString *)key value:(id) value ;

-(void) addKeyField:(NSString *)key value:(id) value ;
-(void) addKeyField:(NSString *)key value:(id) value type:(enum DataType ) type;

-(NSString *)getFieldValueByName:(NSString *) fieldName;
-(NSData *)getFieldDataByName:(NSString *) fieldName;
@end
